package com.AAA.controller.scl;

import com.AAA.entity.*;
import com.AAA.entity.scl.TSclPlane;
import com.AAA.service.scl.TSclPlaneService;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpSession;
import java.util.Date;

/**
 * (TSclPlane)表控制层
 *
 * @author makejava
 * @since 2022-10-28 17:00:23
 */
@RestController
@RequestMapping("tSclPlane")
public class TSclPlaneController {
    /**
     * 服务对象
     */
    @Autowired
    private TSclPlaneService tSclPlaneService;

    @GetMapping
    public LayData queryAll(MyPage myPage, TSclPlane tSclPlane){
        PageInfo pageInfo = tSclPlaneService.queryAll(myPage,tSclPlane);
        return new LayData(pageInfo);
    }

    @RequestMapping
    public LayData checkCode(TSclPlane plane){
        boolean b = tSclPlaneService.selectPlane(plane);
        return new LayData(b);
    }

    @RequestMapping("addPlane")
    @ResponseBody
    public LayData addPlane(TSclPlane plane, HttpSession session){
        User user1 = (User) session.getAttribute("user");
        plane.setCreatetime(new Date());
        plane.setUid(user1.getId());
        System.out.println(plane);
        boolean b = tSclPlaneService.insertPlane(plane);
        return new LayData(b);

    }

    @RequestMapping("getByCode")
    @ResponseBody
    public LayData queryByQyCode(TSclPlane tSclPlane){
        TSclPlane tSclPlane1 = tSclPlaneService.queryByQyCode(tSclPlane);
        return new LayData(tSclPlane1);
    }

    @PostMapping("updatas")
    @ResponseBody
    public LayData queryUser(TSclPlane tSclPlane){

        boolean status=tSclPlaneService.updatas(tSclPlane);
        return new LayData(status);
    }

}
